﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KnowFirstWebApplication
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string v = Request.QueryString["signout"];
                if (null != v && v.ToLower().Equals("expired"))
                    lblExpired.Text = "נא להתחבר שוב למערכת";


            }
        }

        public bool IsAuthenticated(string userName, string password)
        {
            Dal.DatabaseAbstractionLayer dal = new Dal.DatabaseAbstractionLayer();
            return dal.IsAuthenticated(userName, password);
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (IsAuthenticated(tbUserName.Text, tbPassword.Text))
            {
                Session["UserName"] = tbUserName.Text;
                Response.Redirect("Results.aspx");
            }
        }
    }
}
